package com.carter.springframework.beans.factory.support;

import com.sun.istack.internal.Nullable;

import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

public class MethodOverrides {
    private final Set<MethodOverride> overrides = new CopyOnWriteArraySet<>();

    public MethodOverrides() {
    }

    /**
     * Deep copy constructor.
     */
    public MethodOverrides(MethodOverrides other) {
        addOverrides(other);
    }

    public void addOverrides(@Nullable MethodOverrides other) {
        if (other != null) {
            this.overrides.addAll(other.overrides);
        }
    }

    public Set<MethodOverride> getOverrides() {
        return this.overrides;
    }

    /**
     * Return whether the set of method overrides is empty.
     */
    public boolean isEmpty() {
        return this.overrides.isEmpty();
    }
}
